package com.example.codegen;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class TestMatcher {
    public static void main(String[] args) {
//        String typeString = "int0[][]";
////        String regex = "([a-zA-Z0-9]+)(\\[\\])*"; // 匹配基础类型或类名，以及数组维度
//        String regex = "([a-zA-Z][a-zA-Z0-9]*)((\\[\\])*)"; // 匹配基础类型或类名，以及数组维度
//
//        Pattern pattern = Pattern.compile(regex);
//        Matcher matcher = pattern.matcher(typeString);
//
//        if (matcher.matches()) {
//            String typeName = matcher.group(1); // 获取基础类型或类名
//            String dimensions = matcher.group(2); // 获取数组维度
//
//            int dimensionCount = (dimensions.length() + 1) / 2; // 计算数组维度数量
//
//            System.out.println("Type name: " + typeName);
//            System.out.println("Dimension count: " + dimensionCount);
//        } else {
//            System.out.println("Type string does not match the pattern");
//        }
        String input = "method()";
        Pattern pattern = Pattern.compile("(.*?)\\((.*?)\\)");
        Matcher matcher = pattern.matcher(input);
        System.out.println(matcher.groupCount());

        if (matcher.find()) {
            String methodName = matcher.group(1); // 获取方法名
            String parameters = matcher.group(2); // 获取参数
            System.out.println("Method Name: " + methodName);
            System.out.println("Parameters: " + parameters);
        }
        var s = "    s".split("\\s*,\\s*");
        System.out.println(s.length);
        System.out.println(String.join("\\", s));
    }
}
